package com.example.ribbon.web;

import com.example.ribbon.service.GatewayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wangxianchen
 * @create 2017-12-25
 * @desc
 */
@RestController
public class GatewayController {
    private static Logger logger = LoggerFactory.getLogger(GatewayController.class);


    @Autowired
    GatewayService gatewayService;

    @Value("${spring.application.name}")
    String appName;


    @RequestMapping("/hello")
    public Object adminInfo(HttpServletRequest request){
        return "SERVICE "+ appName +" is running";
    }

    @RequestMapping(value = "/hi")
    public String hi(@RequestParam String name){
        return gatewayService.hiService(name);
    }
}
